unit USupplierInvoice;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, AdvPanel, cxGraphics,
  cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel,
  dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, cxGroupBox, DBAdvGlowNavigator,
  cxStyles, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage,
  cxNavigator, Data.DB, cxDBData, cxGridLevel, cxClasses, cxGridCustomView,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, UDMPharmacy,
  cxDBLookupComboBox, cxDropDownEdit, cxCalendar, cxDBEdit, cxTextEdit,
  cxMaskEdit, cxLookupEdit, cxDBLookupEdit, Vcl.StdCtrls, UDMItems, UPharmacyStockSubNew;

type
  TFSupplierInvoice = class(TForm)
    AdvPanel1: TAdvPanel;
    AdvPanelStyler1: TAdvPanelStyler;
    cxGroupBox1: TcxGroupBox;
    AdvPanel2: TAdvPanel;
    DBAdvGlowNavigator1: TDBAdvGlowNavigator;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1supplier_id: TcxGridDBColumn;
    cxGrid1DBTableView1invoice_date: TcxGridDBColumn;
    cxGrid1DBTableView1invoice_total: TcxGridDBColumn;
    cxGrid1DBTableView1currency_id: TcxGridDBColumn;
    cxGrid1DBTableView1currancy_rate: TcxGridDBColumn;
    Label1: TLabel;
    cxDBLookupComboBox1: TcxDBLookupComboBox;
    Label2: TLabel;
    cxDBDateEdit1: TcxDBDateEdit;
    Label3: TLabel;
    cxDBTextEdit1: TcxDBTextEdit;
    Label4: TLabel;
    cxDBLookupComboBox2: TcxDBLookupComboBox;
    Label5: TLabel;
    cxDBTextEdit2: TcxDBTextEdit;
    Label6: TLabel;
    cxDBTextEdit3: TcxDBTextEdit;
    cxDBTextEdit4: TcxDBTextEdit;
    Label7: TLabel;
    procedure DBAdvGlowNavigator1BtnCancel(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnEdit(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnFirst(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnInsert(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnLast(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnNext(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnPost(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnPrior(Sender: TObject);
    procedure DBAdvGlowNavigator1BtnRefresh(Sender: TObject);
    procedure cxDBLookupComboBox2PropertiesEditValueChanged(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FSupplierInvoice: TFSupplierInvoice;

implementation

{$R *.dfm}

procedure TFSupplierInvoice.cxDBLookupComboBox2PropertiesEditValueChanged(
  Sender: TObject);
begin
  DMItems.his_currency.Locate('currency_id',self.cxDBLookupComboBox2.EditValue, []);
  Self.cxDBTextEdit2.EditValue := DMItems.his_currency.FieldByName('currency_rate').Value;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnCancel(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;

  DMPharmacy.his_pharmacy_supplier_invoice.Cancel;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnEdit(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;
  DMPharmacy.his_pharmacy_supplier_invoice.Edit;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnFirst(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;
  DMPharmacy.his_pharmacy_supplier_invoice.First;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnInsert(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;
  DMPharmacy.his_pharmacy_supplier_invoice.Insert;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnLast(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;
  DMPharmacy.his_pharmacy_supplier_invoice.Last;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnNext(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;
  DMPharmacy.his_pharmacy_supplier_invoice.Next;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnPost(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := true;
  DMPharmacy.his_pharmacy_supplier_invoice.Post;
  DMPharmacy.his_pharmacy_supplier_invoice.RefreshRecord;
  Self.AdvPanel1.Enabled := false;
  case MessageDlg('Do you want to add Invoice Detail now ?', mtConfirmation, [mbOK, mbCancel], 0) of
    mrOk:
      begin
        FPharmacyStockSubNew.Show;
      end;
    mrCancel:
      begin
        Self.Close;
      end;
  end;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnPrior(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;
  DMPharmacy.his_pharmacy_supplier_invoice.Prior;
end;

procedure TFSupplierInvoice.DBAdvGlowNavigator1BtnRefresh(Sender: TObject);
begin
  Self.AdvPanel1.Enabled := false;
  DMPharmacy.his_pharmacy_supplier_invoice.RefreshRecord;
end;

procedure TFSupplierInvoice.FormActivate(Sender: TObject);
begin
  DMPharmacy.his_suppliers.Refresh;
end;

end.
